package server;

public interface IServerApplication{
	/**
	 * Main proccess function, this application instantiates the CMM as a thread.
	 * @return Return value for the program
	 */
/*	public void main(String[] args);*/
	
	/*
	 * 		Interface with the CMM
	 */
	
	
	/**
	 * Start servicing a task per request from the CMM, 
	 * this is used to migrate tasks between machines
	 * @param TaskID - Task ID of the new(migrated) task to service
	 * @param Task - Task Context of the(migrated) new task
	 */
	public void StartServicingTask(Integer TaskId, SAGenTaskContext Task);
	
	/**
	 * Stop Servicing a task, per request of the CMM
	 * @param TaskId - which task to stop servicing
	 */
	public void StopServicingTask(Integer TaskId);
	
	/**
	 * Recieve a task ID for a newly created task.
	 * this method is called by the CMM after a NewTask() call from the SA to the CMM,
	 * this method is used to return the TaskId that was obtained from the lower level 
	 * spread network in an asynchoronous manner.
	 * @param TaskId - Task ID of the newly created task
	 * @throws SAExn_UnexpectedTaskId 
	 * @throws SAExn_TaskIdAlreadyPresent 
	 */
	public void ReceiveNewTaskId(Integer TaskId) throws SAExn_UnexpectedTaskId, SAExn_TaskIdAlreadyPresent;
	

	/**
	 * update an old task context with an incremental change
	 * in case a ServerApplication don't want to support incremental changes (we probably won't)
	 * this function can simply return the delta as the updated task context.
	 * this can be used when task contexts are small enough to send as whole or when context updates 
	 * are impossible. 
	 * @param OldContext - old task context data
	 * @param Delta - Incremental change
	 * @return - updated task context
	 */
	public SAGenTaskContext ReconstructTaskContext(SAGenTaskContext OldContext, SAGenTaskContext Delta);
	
	/**
	 * Request user to do Intervent (e.g. network/mahcine configuration) and wait for his acknowledge.
	 * This can be used by CMM to recover from recoverable errors that can be resolved with user
	 * intervention.
	 * @param message - message to show to user
	 */
	public void WaitForUser(String message);

	
	/**
	 * @param ModuleName
	 * @param Entry
	 */
	public void AddLogEntry(String ModuleName, String Entry);
	
	public void UnrecoverableClusterError();
}